﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="TopWinCMS.WebUI.Views.TopWinCMS6.Member.Login" %>

<!doctype html>
<html>
<head runat="server">
    <title></title>
    <%: Styles.Render("~/Templates/TopWinCMS6/Style/css.css") %>
    <link href="../TopWinCMS.css" rel="stylesheet" type="text/css" media="all" />
    <meta charset="utf-8" />
    <meta http-equiv="Pragma" content="No-cach" />
    <script src="{SysPath}/Scripts/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="../JS/TopWinCMS.js"></script>
    <script type="text/javascript">

        function PostLogin()
        {
            var u = $("#<%=TB_UserName.ClientID %>").val();
            var w = $("#<%=TB_PSW.ClientID %>").val();
            var p = $("#<%=TB_PassCode.ClientID %>").val();
            var k = $("#<%=DDL_KeepLong.ClientID %>").val();


            var r = Request.QueryString("redirectURL");
            if (u == "")
            {
                alert("请输入用户名");
                return;
            }
            if (w == "")
            {
                alert("请输入密码");
                return;
            }
            var parameters = "UserName=" + escape(u);
            parameters += "&UserPSW=" + escape(w);
            parameters += "&PassCode=" + p;
            parameters += "&KeepLong=" + 0;
            parameters += "&redirectURL=" + escape(r);

            $.ajax({
                type: "POST",
                url: "../AjaxPostBack.ashx?Action=PostUserLogin",
                data: parameters,
                dataType:"JSON",
                beforeSend: function ()
                {
                    document.getElementById("BT_Login").disabled = true;
                    $("#BT_Login").val("登录中...");
                },
                success: function (info)
                {
                    if (info.Err == "")
                    {
                        if (Request.QueryString("redirectURL") == '')
                            window.location = "Default.aspx";
                        else
                            window.location.href = DecodeURI(Request.QueryString("redirectURL"), false);
                    }
                    else
                    {
                        alert(info.Err);
                        document.getElementById("BT_Login").disabled = false;
                        $("#BT_Login").val("登录");
                    }
                }
            });

        }


        function PassCodeInit()
        {
            if ($('#div_ValidateCode').length > 0)
                $('#div_ValidateCode').show();
            else
                alert("控件不存在");
        }
        $(document).ready(function ()
        {
            if ($("#TB_UserName")[0])
            {
                $("#TB_UserName").focus(PassCodeInit);
            }
            if ($("#TB_PSW")[0])
            {
                $("#TB_PSW").focus(PassCodeInit);
            }
        });
    </script>

</head>
<body>
    <!--#include file="../Header.aspx"-->
    <form id="form1" runat="server">
    <div style="margin-top: 20px; margin-bottom: 20px; margin-left: auto; margin-right: auto;
        width: 280px;">
        <section class="div_ListBox">
      <header>
        <h2>会 员 登 录</h2>
      </header>
      <div class="Content">
        <ul>
          <table style="width: 100%;" id="UserLogin">
                <tr>
                    <td>
                        用户名：
                    </td>
                    <td>
                        <asp:TextBox ID="TB_UserName" runat="server" Width="120"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td>
                        密码：
                    </td>
                    <td>
                        <asp:TextBox ID="TB_PSW" runat="server" Width="120" TextMode="Password"></asp:TextBox>
                    </td>
                </tr>
                <tr id="div_ValidateCode">
                    <td>
                        验证码：
                    </td>
                    <td>
                        <asp:TextBox ID="TB_PassCode" runat="server" Width="60px"></asp:TextBox>
                        <asp:Image ID="Image1" runat="server" onclick="this.src='../PassCode.ashx?n=+ Math.random();'"
                            ToolTip="点击刷新验证码。" align="absmiddle" ImageUrl="../PassCode.ashx" Style="cursor: pointer" />
                    </td>
                </tr>
                <tr>
                    <td>
                        Cookies：
                    </td>
                    <td>
                        <asp:DropDownList ID="DDL_KeepLong" runat="server">
                            <asp:ListItem Value="0" Selected="True">不保存</asp:ListItem>
                            <asp:ListItem Value="1">一天</asp:ListItem>
                            <asp:ListItem Value="30">一月</asp:ListItem>
                            <asp:ListItem Value="999">永久</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="text-align: center">
                        <input class="btn" onclick="PostLogin();" id="BT_Login" type="button" value="登录" />
                        <input class="btn" id="Reset" type="reset" value="清除" name="Reset"/>
                                                 <a href="Reg.aspx">免费注册</a> <a href="GetPassword.aspx">忘记密码？</a>
                    </td>
                </tr>
            </table>
        </ul>
      </div>
    </div>
    </form>
    <!--#include file="../Footer.aspx"-->
</body>
</html>
